

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body layadmin-themealias="default">

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15="">

                    <div class="layui-form" wid100="" lay-filter="">
                        <input type="hidden" name="id" value="{$taginfo.id}" class="layui-input" lay-verify="required" readonly>
                        <div class="layui-form-item">
                            <label class="layui-form-label">标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" value="{$taginfo.title}" class="layui-input" lay-verify="required" placeholder="">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">展示色值</label>
                            <div class="layui-input-inline" style="width: 200px;">
                                <input type="text" name="color" value="{$taginfo.color}" placeholder="点击右侧选择颜色" class="layui-input" id="color-sel-input" lay-verify="required">
                            </div>
                            <div class="layui-inline" style="left: -11px;">
                                <div id="color-sel"></div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">分值</label>
                            <div class="layui-input-block">
                                <input type="text" name="point" value="{$taginfo.point}" class="layui-input" lay-verify="required" placeholder="">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">类型</label>
                            <div class="layui-input-block">
                                <select name="type" lay-verify="required">
                                    {if $taginfo.type == 1}
                                        <option value="1" selected>加分</option>
                                        <option value="0">减分</option>
                                    {else /}
                                        <option value="1">加分</option>
                                        <option value="0" selected>减分</option>
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block text-center">
                                <button class="layui-btn" lay-submit="" lay-filter="tag-add">确认保存</button>
                                <button class="layui-btn layui-btn-primary" id="close">取消</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'colorpicker', 'admin', 'tag'], function() {
        var $ = layui.$
            ,form = layui.form
            ,admin = layui.admin
            ,colorpicker = layui.colorpicker;

        //表单赋值
        colorpicker.render({
            elem: '#color-sel'
            ,color: '{$taginfo.color}'
            ,done: function(color){
                $('#color-sel-input').val(color);
            }
        });

        var index = parent.layer.getFrameIndex(window.name);

        $('#close').on("click",function () {
            parent.layer.close(index);
        });

        form.on('submit(tag-add)', function(obj){
            //提交
            admin.req({
                url: '/admin/setting/edit_tag_post'
                ,data: obj.field
                ,success: function(res){
                    if (res.code == 0){
                        parent.layer.close(index);
                        parent.layer.msg(res.msg, {icon: 1});
                        parent.layui.table.reload('LAY-tag-manage');
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
